const path = require('path')
//const px2rem = require("postcss-px2rem");
function resolve(dir) {
  return path.join(__dirname, dir)
}
// const postcss = px2rem({
//   // 基准大小 baseSize，需要和rem.js中相同
//   remUnit: 14,
// });

process.env.VUE_APP_VERSION = require('./package.json').version;
process.env.VUE_APP_BUILD_TIME = new Date().getTime();

module.exports = {
  outputDir: 'dist/publish-dir',
  publicPath: './',
  filenameHashing: true,
  productionSourceMap: false,
  chainWebpack(config) {
    // set svg-sprite-loader
    config.module
      .rule('svg')
      .exclude.add(resolve('src/icons'))
      .end()
    config.module
      .rule('icons')
      .test(/\.svg$/)
      .include.add(resolve('src/icons'))
      .end()
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .options({
        symbolId: 'icon-[name]'
      })
      .end()
  },
  css: {
    loaderOptions: {
      // postcss: {
      //   plugins: [postcss],
      // },
      sass: {
        sassOptions: {
          outputStyle: 'expanded'
        }
      }
    },
  },
};
